<?php

/**
 * @filename: exmenu.class.php
 * @usage: Extends the user menu with the podcast and PDF stuff
 */

class Display_Exmenu extends Display_Display {

	/**
	 * @function: buildMenu
	 * @usage: Build the user display menu for the podcasts etc
	 */
	public function buildMenu() {
	
		// Create a global db variable
		global $db;
		
		// And an empty html variable
		$html = "";
		
		// We're going to need to make a few queries and some annoying coding decision to make this work, let us soldier on - Food first
		$food = $db->getQuery("SELECT * FROM `promotions` WHERE `category` = '1'", ARRAY_A);
		
		// Signage next
		$sign = $db->getQuery("SELECT * FROM `promotions` WHERE `category` = '4'", ARRAY_A);
		
		// Now sustainable etc
		$sust = $db->getQuery("SELECT * FROM `promotions` WHERE `category` = '2'", ARRAY_A);
		
		// Finally trust
		$trust = $db->getQuery("SELECT * FROM `promotions` WHERE `category` = '3'", ARRAY_A);
		
		// And then the podcasts and PDF's
		$pod = $db->getQuery("SELECT * FROM `uploads` WHERE `type` = 'podcast'", ARRAY_A);
		$pdf = $db->getQuery("SELECT * FROM `uploads` WHERE `type` = 'pdf'", ARRAY_A);
		
		$html .= "<ul class=\"dropdown dropdown-vertical\" style=\"clear:left;\">\n";
		$html .= "<li class=\"dir\"><a href=\"#\">Food / Drink / Loyalty</a></li><ul>";
		
		// Build the menu using these
		foreach ($food as $f) {

			$html .= "<li><a href=\"selectimage.php?sec=ps&amp;category=".$f['category']."&amp;promotion=".$f['id']."\">".$f['nameOfPromotion']."</a></li>\n";
		
		}
		
		$html .= "</ul></ul>\n";
		
		$html .= "<ul class=\"dropdown dropdown-vertical\" style=\"clear:left;\">\n";
		$html .= "<li class=\"dir\"><a href=\"#\">Nutrition</a></li><ul>";
		
		// Build the menu using these
		foreach ($pdf as $p) {

			$html .= "<li><a href=\"downloadpdf.php?sec=ps&amp;id=".$p['id']."\">".$p['title']."</a></li>\n";
		
		}
		
		$html .= "</ul></ul>\n";
		
		$html .= "<ul class=\"dropdown dropdown-vertical\" style=\"clear:left;\">\n";
		$html .= "<li class=\"dir\"><a href=\"#\">Signage / Hardware</a></li><ul>";
		
		// Build the menu using these
		foreach ($sign as $s) {

			$html .= "<li><a href=\"selectimage.php?sec=ps&amp;category=".$s['category']."&amp;promotion=".$s['id']."\">".$s['nameOfPromotion']."</a></li>\n";
		
		}
		
		$html .= "</ul></ul>\n";
		
		$html .= "<ul class=\"dropdown dropdown-vertical\" style=\"clear:left;\">\n";
		$html .= "<li class=\"dir\"><a href=\"#\">Archive</a></li><ul>";
		
		// Build the menu using these
		foreach ($pod as $po) {

			$html .= "<li><a href=\"downloadpdf.php?sec=ps&amp;id=".$po['id']."\">".$po['title']."</a></li>\n";
		
		}
		
		$html .= "</ul></ul>\n";
		
		$html .= "<ul class=\"dropdown dropdown-vertical\" style=\"clear:left;\">\n";
		$html .= "<li class=\"empty\"><a href=\"#\">Sustainable / Ethical / Local</a></li><ul>";
		
		// Build the menu using these
		foreach ($sust as $su) {

			$html .= "<li><a href=\"selectimage.php?sec=ps&amp;category=".$su['category']."&amp;promotion=".$su['id']."\">".$su['nameOfPromotion']."</a></li>\n";
		
		}
		
		$html .= "</ul></ul>\n";
		
		$html .= "<ul class=\"dropdown dropdown-vertical\" style=\"clear:left;\">\n";
		$html .= "<li class=\"dir\"><a href=\"#\">Trust</a></li><ul>";
		
		// Build the menu using these
		foreach ($trust as $t) {

			$html .= "<li><a href=\"selectimage.php?sec=ps&amp;category=".$t['category']."&amp;promotion=".$t['id']."\">".$t['nameOfPromotion']."</a></li>\n";
		
		}
		
		$html .= "</ul></ul>\n";
		
		$html .= "<ul class=\"dropdown dropdown-vertical\" style=\"clear:left;\">\n";
		$html .= "<li class=\"link\"><a href=\"feedback.php\">Feedback</a></li>";
		$html .= "</ul>\n";
		
		echo $html;
	
	}

}

?>